package ${basePackage}.controller;

import ${basePackage}.model.${modelNameUpperCamel};
import ${basePackage}.service.${modelNameUpperCamel}Service;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import com.mass.core.utils.*;

/**
* Created by ${author} on ${date}.
*/
@RestController
@RequestMapping("${baseRequestMapping}")
public class ${modelNameUpperCamel}Controller {

    @Autowired
    private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service;

    /**
    * 增加
    * @param ${modelNameLowerCamel}
    * @return
    */
	@ApiOperation( value = "添加一个实例",notes = "添加${modelNameLowerCamel}" )
    @PostMapping("/insert")
    public AjaxResponse insert(${modelNameUpperCamel} ${modelNameLowerCamel}) {
        int number = ${modelNameLowerCamel}Service.insert(${modelNameLowerCamel});
        return AjaxResponse.success(number);
    }

    /**
    * 删除
    * @param id
    * @return
    */
	@ApiOperation( value = "添加一个实例",notes = "删除${modelNameLowerCamel}" )
	@ApiImplicitParam( name="id" , value="id" , paramType = "query",dataType = "Long",required = true)
    @PostMapping("/delete")
    public AjaxResponse delete(@NotNull(message = "id不能为空") Long id) {
        int number = ${modelNameLowerCamel}Service.delete(id);
        return AjaxResponse.success(number);
    }

    /**
    * 修改
    * @param ${modelNameLowerCamel}
    * @return
    */
	@ApiOperation( value = "修改",notes = "修改${modelNameLowerCamel}" )
    @PostMapping("/update")
    public AjaxResponse update(${modelNameUpperCamel} ${modelNameLowerCamel}) {
        int number = ${modelNameLowerCamel}Service.update(${modelNameLowerCamel});
        return AjaxResponse.success(number);
    }

    /**
    * 通过id查找
    * @param id
    * @return
    */
	@ApiOperation( value = "根据ID查找实例",notes = "通过id查找详情" )
    @ApiImplicitParam( name="id" , value="id" , paramType = "query",dataType = "Long",required = true)
    @PostMapping("/selectById")
    public AjaxResponse selectById(@NotNull(message = "id不能为空") Long id) {
	   ${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.selectById(id);
        return AjaxResponse.success(${modelNameLowerCamel});
    }

    /**
    * 分页条件查找
    * @param input 输入对象
    * @return
    */
	@ApiImplicitParams({
    	@ApiImplicitParam(value = "列表查询", paramType = "query", required = false, dataType = "${modelNameUpperCamel}"),
    	@ApiImplicitParam(name = "page", value = "当前页", paramType = "query", required = true, dataType = "Integer"),
    	@ApiImplicitParam(name = "limit", value = "查询行", paramType = "query", required = true, dataType = "Integer")
    })
    @GetMapping(value = "/selectPage")
    public AjaxResponse selectPage(${modelNameUpperCamel} ${modelNameLowerCamel},Integer page ,Integer limit) {
        return ${modelNameLowerCamel}Service.selectPage(${modelNameLowerCamel},page,limit);
    }
}
